package com.pocketsweet.ui.fragments;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.pocketsweet.R;
import com.pocketsweet.service.UserService;
import com.pocketsweet.ui.uilib.MyBitmapFactory;
import com.pocketsweet.ui.uilib.myTextViewShow;
import com.squareup.picasso.Picasso;

public class WelcomeTwo extends Fragment {
	@ViewInject(R.id.mtvShow)
	private myTextViewShow mtvShow;
//
	@ViewInject(R.id.welcome2)
	private ImageView welcome2;

	private boolean isShow = false;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_welcome_2, null);
		ViewUtils.inject(this, rootView);
		return rootView;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
//		welcome2.setImageDrawable(getResources().getDrawable(
//				R.drawable.welcome2));
		UserService.displaySplashImage(R.drawable.welcome2, welcome2);

//		Picasso.with(getActivity()).load(R.drawable.welcome2).into(welcome2);  
//		welcome2.setImageBitmap(MyBitmapFactory
//				.decodeSampledBitmapFromResource(getResources(),
//						R.drawable.welcome2, 260, 596));

	}

	public void textShow() {
		if (isShow == false) {
			isShow = true;
			mtvShow.startShow();
		} else {
			mtvShow.setText(mtvShow.getTextString());
		}
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		releaseImageViews();

	}


	private void releaseImageViews() {
		MyBitmapFactory.releaseImageViewResouce(welcome2);
	}

}
